import java.awt.Color;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.LayoutStyle.ComponentPlacement;

public class Notification extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final int HEIGHT = 205;
	public static final int WIDTH = 405;

	public static JTextArea ContextArea;
	public static String Message = "";
	public static int impression = 0;
	public static final String exit_img = "logo\\exit_ico.gif";
	private JPanel contentPanel;

	public Notification() {
		setSize(405, 209);
		setType(Type.POPUP);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

		setUndecorated(true);
		setVisible(true);

		new MStyleFrame(this);

		GraphicsEnvironment ge = GraphicsEnvironment
				.getLocalGraphicsEnvironment();
		Rectangle rect = ge.getMaximumWindowBounds();

		setLocation(
				(int) (rect.getBounds().getWidth() - getSize().getWidth()),
				(int) (rect.getBounds().getHeight() - getSize().getHeight()) - 40);

		contentPanel = new JPanel();
		contentPanel.setBackground(new Color(70, 130, 180));

		setContentPane(contentPanel);

		JScrollPane scrollPane = new JScrollPane();
		ContextArea = new JTextArea(Message);
		ContextArea.setBackground(new Color(176, 196, 222));
		ContextArea.setEditable(false);
		ContextArea.setFont(new Font("Arial", Font.PLAIN, 14));
		ContextArea.setLineWrap(true);
		scrollPane.setViewportView(ContextArea);

		JButton butShare = new JButton();
		butShare.setBackground(new Color(143, 188, 143));
		butShare.setText("Share");
		butShare.setFont(new Font("SansSerif", Font.PLAIN, 10));
		butShare.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new Authorization(Message);
			}
		});

		JButton butExit = new JButton();
		butExit.setIcon(new ImageIcon(exit_img));
		butExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				dispose();
			}
		});

		JButton Dislike = new JButton("Dislike");
		Dislike.setFont(new Font("SansSerif", Font.PLAIN, 10));
		Dislike.setForeground(SystemColor.textText);
		Dislike.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setImpression(-1);
			}
		});

		JButton Like = new JButton("Like");
		Like.setFont(new Font("SansSerif", Font.PLAIN, 10));
		Like.setForeground(SystemColor.textText);
		Like.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setImpression(1);
			}
		});

		GroupLayout gl_contentPanel = new GroupLayout(contentPanel);
		gl_contentPanel
				.setHorizontalGroup(gl_contentPanel
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_contentPanel
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												gl_contentPanel
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																butExit,
																Alignment.TRAILING,
																GroupLayout.PREFERRED_SIZE,
																22,
																GroupLayout.PREFERRED_SIZE)
														.addGroup(
																Alignment.TRAILING,
																gl_contentPanel
																		.createSequentialGroup()
																		.addComponent(
																				butShare)
																		.addPreferredGap(
																				ComponentPlacement.RELATED,
																				211,
																				Short.MAX_VALUE)
																		.addComponent(
																				Like,
																				GroupLayout.PREFERRED_SIZE,
																				57,
																				GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				Dislike))
														.addComponent(
																scrollPane,
																GroupLayout.DEFAULT_SIZE,
																388,
																Short.MAX_VALUE))
										.addContainerGap()));
		gl_contentPanel
				.setVerticalGroup(gl_contentPanel
						.createParallelGroup(Alignment.TRAILING)
						.addGroup(
								gl_contentPanel
										.createSequentialGroup()
										.addContainerGap(
												GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addComponent(butExit,
												GroupLayout.PREFERRED_SIZE, 21,
												GroupLayout.PREFERRED_SIZE)
										.addGap(1)
										.addComponent(scrollPane,
												GroupLayout.PREFERRED_SIZE,
												147, GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												ComponentPlacement.RELATED)
										.addGroup(
												gl_contentPanel
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																gl_contentPanel
																		.createParallelGroup(
																				Alignment.BASELINE)
																		.addComponent(
																				Like)
																		.addComponent(
																				butShare,
																				GroupLayout.PREFERRED_SIZE,
																				28,
																				GroupLayout.PREFERRED_SIZE))
														.addComponent(
																Dislike,
																GroupLayout.PREFERRED_SIZE,
																26,
																GroupLayout.PREFERRED_SIZE))
										.addGap(116)));

		contentPanel.setLayout(gl_contentPanel);

	}

	public static int getImpression() {
		return impression;
	}

	public static void setImpression(int i) {
		impression = i;
	}

	public void setContent(String aMessage) {

		Message = aMessage;
		ContextArea.setText(Message);
	}
}